package commerce.test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.Date;
import java.util.List;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import commerce.business.CommerceBusiness;
import commerce.hibernate.po.Member;
import commerce.hibernate.po.Product;
import commerce.hibernate.po.ProductCategory;
import commerce.hibernate.po.Shop;

public class commercebusinesstest {
	CommerceBusiness bus=new CommerceBusiness();
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}
	@Test
	public void InsertTestData()
	{//安装测试数据
		
	}
	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Test
	public void testGetCategoryByIdInt() {
		fail("Not yet implemented");
	}

	@Test
	public void testSaveCategory() {
		ProductCategory c=new ProductCategory();
		c.setCategoryName("vagetable");
		c.setParentId(null);		
		bus.saveCategory(c);
	}

	@Test
	public void testGetAllCategory() {
		List<ProductCategory> cList = bus.getAllCategory();
		for(ProductCategory c : cList) {
			System.out.println(c.getId() + "\t" + c.getCategoryName());
		}
		// fail("Not yet implemented");
	}

	@Test
	public void testDeleteCategory() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetCategoryByIdInteger() {
		fail("Not yet implemented");
	}

	@Test
	public void testDeleteCategoryById() {
		Integer cId=1;
		assertTrue("delete failed",bus.deleteCategoryById(cId));
	}

	@Test
	public void testDeleteCategoryBatch() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetCategoryByNameStringIntInt() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetCategoryByNameString() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetShopById() {
		fail("Not yet implemented");
	}

	@Test
	public void testSaveShop() {
		Shop shop=new Shop();
		shop.setShopName("first shop");
		// assertFalse("save shop access",bus.saveShop(shop));
	}

	@Test
	public void testDeleteShop() {
		fail("Not yet implemented");
	}

	@Test
	public void testDeleteShopById() {
		fail("Not yet implemented");
	}

	@Test
	public void testDeleteShopBatch() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetAllShop() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetProductById() {
		Product p = bus.getProductById(1);
		System.out.println();
		// fail("Not yet implemented");
	}

	@Test
	public void testSaveProduct() {
		Product p = new Product();
		p.setProductName("p name");
		// p.setShopId(1);
		p.setProductAbstract("p abstract");
		p.setProductIntroduction("p introduction");
		p.setProductPic("p pic");
		p.setProductPrice(33.0f);
		p.setIsRecommand(1);
		p.setPublishDate(new Date());
		p.setIsVisiable(1);
		bus.saveProduct(p);
		// fail("Not yet implemented");
	}

	@Test
	public void testDeleteProduct() {
		fail("Not yet implemented");
	}

	@Test
	public void testDeleteProductById() {
		fail("Not yet implemented");
	}

	@Test
	public void testDeleteProductBatch() {
		Integer[] idArray = {1, 2};
		bus.deleteProductBatch(idArray);
		// fail("Not yet implemented");
	}

	@Test
	public void testGetAllProduct() {
		List<Product> pList = bus.getAllProduct();
		for (Product p : pList) {
			System.out.println(p.getId() + "\t" + p.getProductName());
		}
		// fail("Not yet implemented");
	}
	
	@Test
	public void testSaveMember() {
		Member m = new Member();
		m.setName("西门吹雪");
		m.setPassword("123456");
		m.setAddress("西门吹雪的地址");
		m.setMarketname("market name");
		m.setPrincipal("principal ");
		m.setDeleteflag(1);
		m.setDeleteflag(1);
		m.setValidatecode("sdfsdf");
		m.setValidateflag(1);
		m.setMail("ch001ao@qq.com");
		bus.saveMember(m);
	}

}
